<%--
Document : Home
Created on : Apr 21, 2013, 10:59:58 PM
Author : Sean
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="databaseproject.Products"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@page import="databaseproject.*, business.Cart;" contentType="text/html" pageEncoding="UTF-8"%>
<% 

//session.setAttribute("cart", cart);
Cart cart = (Cart) session.getAttribute("cart");
            if (cart == null)
            {
                cart = new Cart();
                session.setAttribute("cart", cart);
            }

 ArrayList<Products> items = (ArrayList<Products>) request.getAttribute("results");

 
                
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>IST 411</title>
        <link rel="stylesheet" type="text/css" href="site.css">

        <script type="text/javascript">

            function submit(office)
            {
                alert('Item was added to Cart.');
                
                office.submit();
            }
            
            function submit(photoShop)
            {
                alert('Item was added to Cart.');
                
                photoShop.submit();
            }
            
            function submit(dream)
            {
                alert('Item was added to Cart.');
                
                dream.submit();
            }
            
            function submit(submitForm)
            {
                                
                submitForm.submit();
            }
            

        </script>

    </head>
    <body>
        <div id="Main-wrapper">

            <div id="header-wrapper">
                <div id="header">
                    <div class="header-content">
                        IST 411 E-Commerce
                    </div>
                </div>

                <div id="nav">
                    <ul>
                        <li><a href="index.jsp">Home</a></li>
                        <li><a class="active" href="#">Browse</a></li>
                        <li>
                            <a href="shoppingcart.jsp">Shopping Cart</a>
                        </li>
                        <li><a href="shippingcheckout.jsp">Checkout</a></li>
                    </ul>
                </div>
            </div>

            <div id="Main-content">
                <div id="catalog">
                    <div style="text-align: center; font-weight: bold; width: 194px; background: #6699FF; padding:3px; border-bottom: 2px solid #333300;">Categories</div>

                    <ul class="catalog-list">
                        <li><a class="catalog-list" href="BrowseServlet?catalog_id=1">Software</a></li>
                        <li><a class="catalog-list" href="BrowseServlet?catalog_id=2">Hardware</a></li>
                    </ul>
                </div>
                <div class="catalog-content">
                    <h1> Find Our Great Deals </h1>
                    <hr/>
                    <%
                         for (Products item : items)
                       {
                             
                                                         
                    %>
                    <div style="border: 1px solid black; height: 150px; margin-top: 10px; border-radius: .25em; box-shadow: 1px 2px 3px #ccccff;">
                        <div style="float: left; width: 200px; height: 150px; margin-left: 20px; margin-top: 10px;">
                            <img src="<% out.println(request.getContextPath() + item.getImage_link()); %>" width="150" height="125" />

                        </div>
                        <div style="float: left; width: 500px; height: 150px; padding: 5px;">
                            <div>
                                <strong><% out.print(item.getName()); %></strong>
                                <br/>
                                <% out.print(item.getDescription()); %>
                            </div>
                            <div style="margin-top: 80px; text-align: right;">
                                <form action="CartServlet" method="post" name="dream">
                                    <strong>$ <% out.print(item.getPrice()); %></strong>  --
                                    <input type="hidden" name="productCode" value="<%= item.getProduct_id() %>" />
                                    <input type="hidden" name="quantity" value="1" />
                                    <input type="submit" value="Add To Cart" />
                                </form>
                            </div>
                        </div>
                    </div>
                    
                    <% 
   
                           session.setAttribute("cart", cart);
   
   } %>
                </div>
                <div style="clear: both;"></div>
            </div>
            <div id="footer">
                &copy; 2013 | All Rights Reserved
            </div>
        </div>
    </body>
</html>